package net.pimpas.web.jsf.components.focus;

import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;

import net.pimpas.web.jsf.util.ComponentInformation;

public class UIFocus extends UIComponentBase {

	public static final String COMPONENT_TYPE			= ComponentInformation.COMPONENT_PREFIX_TYPE+".focus";
	public static final String COMPONENT_FAMILY			= ComponentInformation.COMPONENT_PREFIX_FAMILY+".focus";
	public static final String COMPONENT_RENDER_TYPE	= ComponentInformation.COMPONENT_PREFIX_RENDER+".focus";
	
	private String forComponent;
	
	@Override
	public Object saveState(FacesContext context) {
		Object[] ob = new Object[2];
		ob[0] = super.saveState(context);
		ob[1] = this.getForComponent();
		
		return ob;
	}
	
	@Override
	public void restoreState(FacesContext context, Object state) {
		Object[] ob = (Object[]) state;
		super.restoreState(context, ob[0]);
		this.setForComponent((String) ob[1]);
	}
	
	@Override
	public String getFamily() {
		return COMPONENT_FAMILY;
	}
	
	@Override
	public String getRendererType() {
		return COMPONENT_RENDER_TYPE;
	}
	
	@Override
	public boolean getRendersChildren() {
		return true;
	}

	public String getForComponent() {
		return forComponent;
	}

	public void setForComponent(String forComponent) {
		this.forComponent = forComponent;
	}
}